home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / extra / fhprintf.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  915b  |  52 lines

  1.  
  2. /*
  3.  *  FHPRINTF.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  *
  9.  *  int r = fhprintf(DOSHANDLE, ctl, ...)
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <stdarg.h>
  14. #include <clib/dos_protos.h>
  15. #include <lib/misc.h>
  16.  
  17. #ifndef HYPER
  18. #define HYPER(x) x
  19. #endif
  20. /*
  21.  *  last arg must be pointer to maintain compatibility with pfmt()
  22.  *  when registered args are used.
  23.  */
  24.  
  25. static unsigned int
  26. _fhwrite(buf, elmsize, elms, fh)
  27. char *buf;
  28. size_t elmsize;
  29. size_t elms;
  30. void *fh;
  31. {
  32.     int r = Write((BPTR)fh, buf, elmsize * elms);
  33.     if (r >= 0)
  34.     r = r / elmsize;
  35.     return(r);
  36. }
  37.  
  38. int
  39. HYPER(fhprintf)(fh, ctl, ...)
  40. long fh;        /*    equiv to BPTR    */
  41. const char *ctl;
  42. {
  43.     int error;
  44.     va_list va;
  45.  
  46.     va_start(va, ctl);
  47.     error = _pfmt(ctl, va, _fhwrite, (void *)fh);
  48.     va_end(va);
  49.     return(error);
  50. }
  51.  
  52.